package com.rlz.base.design.chain

/**
 * Created by RLZ
 * on 2021/10/21
 *
 */
class InterceptChainHandler<T> {
    var mFirst: InterceptChain<T>? = null

    fun add(data: InterceptChain<T>) {
        if (mFirst == null) {
            mFirst = data
            return
        }

        var node = mFirst!!
        while (true) {
            if (node.mNext == null) {
                node.mNext = data
                break
            }
            node = node.mNext!!
        }
    }

    fun intercept(ars: T) {
        mFirst?.intercept(ars)
    }
}